package com.dream.dream_ioc.core;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author wenpan
 */
public class SimpleAliasRegistry implements AliasRegistry {

    private final Map<String, String> aliasMap = new ConcurrentHashMap<>(16);

    public String canonicalName(String name) {
        String canonicalName = name;
        String resolveName;
        do {
            resolveName = this.aliasMap.get(name);
            if (resolveName != null) {
                canonicalName = resolveName;
            }
        }
        while (resolveName != null);
        return canonicalName;
    }

}
